fix(resources): improve custom_field attribute handling to avoid permanent diffs#667
Open
xabinapal wants to merge 7 commits intoe-breuninger:masterfrom
Open
fix(resources): improve custom_field attribute handling to avoid permanent diffs#667xabinapal wants to merge 7 commits intoe-breuninger:masterfrom
xabinapal wants to merge 7 commits intoe-breuninger:masterfrom
Conversation
Contributor
Author
|
There are two unrelated (but required) changes in this PR:
|
This was referenced Dec 24, 2024
Signed-off-by: Xabier Napal <xabier.napal@dvzr.io>
Signed-off-by: Xabier Napal <xabier.napal@dvzr.io>
Signed-off-by: Xabier Napal <xabier.napal@dvzr.io>
Signed-off-by: Xabier Napal <xabier.napal@dvzr.io>
Signed-off-by: Xabier Napal <xabier.napal@dvzr.io>
Signed-off-by: Xabier Napal <xabier.napal@dvzr.io>
Signed-off-by: Xabier Napal <xabier.napal@dvzr.io>
|
Friendly ping. Are there plans to merge this any time soon? We really need this bug fixed for our use of the netbox provider to function correctly. |
|
Hi! 👋 Do you have any plans to merge it soon? |
Contributor
|
@xabinapal this permanent drift have been mitigated in v5.2.1. Would you mind rebasing on master though? I think this contribution is still very relevant. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves the handling of the
custom_fieldsattribute present in many resources. The NetBox API always returns all custom fields for a particular object, whether they are set or not, with unset fields being represented as nulls or empty strings.Currently, this behavior causes permanent differences in execution plans if users do not specify all custom fields, even when only some of them have values. This is common when adding a new custom field to an object that is already managed in Terraform. All the resources created will then have a difference unless the user includes the new custom field in the resource definition, even if they don't want to set a value for it.
To address this, the
custom_fieldsattribute has been marked asComputed, allowing it to be modified internally. ACustomizeDifffunction has been added to the schema of all resources using custom fields to manage the internal state of this attribute effectively and identify real differences and fake ones.Also, this issue has been noticed before in some open pull requests, including #242 and #632. This change should resolve the permanent diff behaviour in the tests of those PRs.